﻿<!--
Copyright © Pavel Fedarovich, 2010-2012

This file is part of AvalonWizard.
 
You may at your option receive a license to Avalon Wizard under 
either the terms of the Apache License version 2.0 or 
the GNU Lesser General Public License (LGPL) version 2.1 or any later version.
 
AvalonWizard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
You may obtain a copy of the Apache License at [http://www.apache.org/licenses/LICENSE-2.0].
You may obtain a copy of the LGPL at [http://www.gnu.org/licenses/].
-->
<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:AvalonWizard" 
    xmlns:conv="clr-namespace:AvalonWizard.Converters" 
    xmlns:aero="clr-namespace:AvalonWizard.Aero" 
    xmlns:s="clr-namespace:System;assembly=mscorlib">

    <conv:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <conv:BooleanInverterConvertor x:Key="BooleanInverter" />
    <conv:VisibilityMultiConverter x:Key="VisibilityMultiConverter" />

    <Style TargetType="{x:Type local:WizardPage}" x:Key="Aero_WizardPageStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:WizardPage}">
                    <aero:AeroWizardPageChrome>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Border Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <ContentPresenter Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" VerticalAlignment="Center" />
                            </Border>
                            <Border Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="{TemplateBinding Padding}">
                                <ContentPresenter />
                            </Border>
                        </Grid>
                    </aero:AeroWizardPageChrome>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate DataType="s:String">
                    <TextBlock Grid.Row="0" Grid.Column="0" Foreground="#003399" FontFamily="Segoe UI" FontWeight="Regular" FontSize="12pt" Text="{Binding}" Margin="38,19" TextWrapping="Wrap" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate TargetType="{x:Type local:Wizard}" x:Key="Aero_ControlTemplate">
        <Grid Background="Transparent">
            <Grid.Resources>
                <Style TargetType="{x:Type local:WizardPage}" BasedOn="{StaticResource Aero_WizardPageStyle}" />
            </Grid.Resources>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <aero:AeroWizardHeader Grid.Row="0" GlowStyle="{Binding Path=(local:AeroWizard.GlowStyle), RelativeSource={RelativeSource TemplatedParent}}" />

            <ContentPresenter Grid.Row="1" Content="{TemplateBinding CurrentPage}" />
            <Grid Grid.Row="2" Background="{TemplateBinding Background}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.Resources>
                    <Style TargetType="Button">
                        <Setter Property="Margin" Value="2,10" />
                        <Setter Property="Padding" Value="12,1" />
                    </Style>
                </Grid.Resources>

                <Button Grid.Column="1" IsDefault="True" Content="{TemplateBinding NextButtonContent}" Command="{x:Static Member=local:WizardCommands.NextPage}">
                    <Button.Visibility>
                        <MultiBinding Converter="{StaticResource VisibilityMultiConverter}" ConverterParameter="ALL">
                            <Binding Path="IsLastPage" Converter="{StaticResource BooleanToVisibilityConverter}" ConverterParameter="INVERT">
                                <Binding.RelativeSource>
                                    <RelativeSource Mode="TemplatedParent" />
                                </Binding.RelativeSource>
                            </Binding>
                            <Binding Path="CurrentPage.ShowNext" Converter="{StaticResource BooleanToVisibilityConverter}">
                                <Binding.RelativeSource>
                                    <RelativeSource Mode="TemplatedParent" />
                                </Binding.RelativeSource>
                            </Binding>
                        </MultiBinding>
                    </Button.Visibility>
                </Button>
                <Button Grid.Column="2" IsDefault="True" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsLastPage, 
                                        Converter={StaticResource BooleanToVisibilityConverter}}" Content="{TemplateBinding FinishButtonContent}" Command="{x:Static Member=local:WizardCommands.Finish}" />
                <Button Grid.Column="3" IsCancel="True" Margin="10" Content="{TemplateBinding CancelButtonContent}" Command="{x:Static Member=local:WizardCommands.Cancel}" Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CurrentPage.ShowCancel,
                                        Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=HIDE, FallbackValue=Visible}" />
            </Grid>
        </Grid>
    </ControlTemplate>
</ResourceDictionary>